<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>binfast - 代码生成器</title>
    <link rel="stylesheet" type="text/css" href="${ctxPath}/plugins/layui/css/layui.css" media="all"/>
    <script type="text/javascript" src="${ctxPath}/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="${ctxPath}/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="${ctxPath}/js/common.js"></script>
    <script type="text/javascript" src="${ctxPath}/js/codeApi.js"></script>

    <script>
        Common.ctxPath= '${ctxPath}';
        //config的设置是全局的
        layui.config({
            base : Common.ctxPath+"/js/",
        });
    </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">binfast 代码生成器</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item">
                <a href="javascript:;">其它系统</a>
                <dl class="layui-nav-child">
                    <dd><a href="">邮件管理</a></dd>
                    <dd><a href="">消息管理</a></dd>
                    <dd><a href="">授权管理</a></dd>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    管理员
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item"><a href="">代码生成</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <blockquote class="layui-elem-quote layui-text">
                每次生成代码后，页面会展示生成的路由。切勿频繁刷新，导致新路由未复制！
                <div>注：表名前缀除sql，以及实体的表名外，不参与代码生成</div>
            </blockquote>
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>代码生成区域</legend>
            </fieldset>
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" > 表名前缀</label>
                        <div class="layui-input-inline">
                            <input type="text" name="preTableName" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" ><span style="color: red">*</span> 表名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="tableName" required lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" ><span style="color: red">*</span> 实体展示名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="tableTitle" required lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="all">生成全部代码 </button>
                        <button class="layui-btn" lay-submit="" lay-filter="java">仅生成Java代码 </button>
                        <button class="layui-btn" lay-submit="" lay-filter="page">仅生成页面代码 </button>
                        <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                    </div>
                </div>
            </form>
            <div style="padding: 20px; background-color: #F2F2F2;">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header"><legend style="font-size: 20px">路由信息  ：</legend></div>
                            <div class="layui-card-body" >
                                ------------- 以下是自动生成路由，需手动复制 --------
                                <div id="routes_content"></div>
                                </br>
                                ------------- 以上是自动生成路由，需手动复制 --------
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © binfast.com - 代码生成器
    </div>
</div>
<script>
    //JavaScript代码区域
    layui.use(['element','form','codeApi'], function(){
        var element = layui.element;
        var form = layui.form
            ,layer = layui.layer
            ,codeApi = layui.codeApi;

        //监听提交
        var that = this;
        form.on('submit(all)', function(data){
            that.codeApi.all(data.field,function (resp) {
                $('#routes_content').html($('#routes_content').html()+resp)
                layer.alert('生成成功', { title: '提示' })
            })
            return false;
        });
        //监听提交
        form.on('submit(java)', function(data){
            that.codeApi.java(data.field,function (resp) {
                layer.alert('生成成功', { title: '提示' })
            })
            return false;
        });
        //监听提交
        form.on('submit(page)', function(data){
            that.codeApi.page(data.field,function (resp) {
                $('#routes_content').html($('#routes_content').html()+resp)
                layer.alert('生成成功', { title: '提示' })
            })
            return false;
        });
    });
</script>
</body>
</html>